package util;


import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Phạm huy Đức Hàm hỗ trợ định dạng dữ liệu kiểu XML
 */
public class uXML {

   public uXML() {
   }

   public static Document loadXMLFromString(String xml) {
      try {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         InputSource is = new InputSource(new StringReader(xml));
         return builder.parse(is);
      } catch (Exception ex) {
         Logger.getLogger(uXML.class.getName()).log(Level.SEVERE, null, ex);
         return null;
      }
   }
}
